﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;

namespace BlobTowerDefense
{
    public partial class HelpPage : PhoneApplicationPage
    {
        public HelpPage()
        {
            InitializeComponent();
        }

        private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
        {
            BitmapImage imageBackground;
            if ((e.Orientation & PageOrientation.Landscape) == (PageOrientation.Landscape))
            {
                imageBackground = new BitmapImage(new Uri("../Images/Backgrounds/Background_Help_Landscape.png", UriKind.Relative));
            }
            else
            {
                imageBackground = new BitmapImage(new Uri("../Images/Backgrounds/Background_Help_Portrait.png", UriKind.Relative));
            }

            if (imageBackground != null)
            {
                ((ImageBrush)LayoutRoot.Background).ImageSource = imageBackground;
            }
        }

        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            animation_Menu_Hide_FromUp.Completed += new EventHandler(animation_Menu_Hide_FromUp_Completed);
            animation_Menu_Hide_FromUp.Begin();
            e.Cancel = true;
        }

        void animation_Menu_Hide_FromUp_Completed(object sender, EventArgs e)
        {
            animation_Menu_Hide_FromUp.Completed -= new EventHandler(animation_Menu_Hide_FromUp_Completed);
            NavigationService.Navigate(new Uri("/Pages/MainPage.xaml", UriKind.Relative));
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            animation_Menu_Show_FromDown.Begin();
            base.OnNavigatedTo(e);
        }
    }
}